package com.ewei.web.authority.controller;

import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ewei.web.authority.vo.RoleVo;
import com.ewei.web.common.json.resolver.JsonModel;
import com.ewei.web.common.json.resolver.JsonModelMap;
import com.ewei.web.common.response.ResponseVO;

@Controller
@RequestMapping("/json")
public class TestJson {
	@Resource
	private Properties config;
	@RequestMapping("/test")
	@ResponseBody
	public Object Map(@JsonModel JsonModelMap model){
		Set<Entry<String,Object>> entrySet = model.getMap().entrySet();
		for(Entry<String,Object> entry:entrySet){
			System.out.println("key:-->"+entry.getKey()+" value:-->"+entry.getValue());
		}
		return new ResponseVO();
	}
	@RequestMapping("/test2")
	@ResponseBody
	public Object Map(@JsonModel @Validated RoleVo model,BindingResult result){
		if(result.hasErrors()){
			System.out.println(result.getFieldError().getDefaultMessage());
		}
		System.out.println(model.getName());
		return new ResponseVO();
	}
	@RequestMapping("/props")
	public void props(){
		System.out.println(config.getProperty("testTag"));
	}
}
